﻿namespace Plugins.Xml.Serialization
{
    using System;

    public sealed class BooleanRuntimeSerializer : XmlRuntimeSerializer<bool>
    {
        private BooleanRuntimeSerializer() { }
        private static BooleanRuntimeSerializer _instance = new BooleanRuntimeSerializer();
        public static BooleanRuntimeSerializer Instance { get { return _instance; } }
        protected override bool Read(IXmlPropertyReader reader, string propertyName)
        {
            return Boolean.Read(reader, propertyName);
        }
        protected override bool Read(IXmlPropertyReader reader, int index)
        {
            return Boolean.Read(reader, index);
        }
        protected override void Write(Boolean value, IXmlPropertyWriter writer, string propertyName)
        {
            Boolean.Write(writer, propertyName, value);
        }
        protected override void Write(Boolean value, IXmlPropertyWriter writer, int index)
        {
            Boolean.Write(writer, index, value);
        }
    }
    public sealed class ByteRuntimeSerializer : XmlRuntimeSerializer<byte>
    {
        private ByteRuntimeSerializer() { }
        private static ByteRuntimeSerializer _instance = new ByteRuntimeSerializer();
        public static ByteRuntimeSerializer Instance { get { return _instance; } }
        protected override Byte Read(IXmlPropertyReader reader, string propertyName)
        {
            return Byte.Read(reader, propertyName);
        }
        protected override Byte Read(IXmlPropertyReader reader, int index)
        {
            return Byte.Read(reader, index);
        }
        protected override void Write(byte value, IXmlPropertyWriter writer, string propertyName)
        {
            Byte.Write(writer, propertyName, value);
        }
        protected override void Write(byte value, IXmlPropertyWriter writer, int index)
        {
            Byte.Write(writer, index, value);
        }
    }
    public sealed class Int16RuntimeSerializer : XmlRuntimeSerializer<Int16>
    {
        private Int16RuntimeSerializer() { }
        private static Int16RuntimeSerializer _instance = new Int16RuntimeSerializer();
        public static Int16RuntimeSerializer Instance { get { return _instance; } }
        protected override Int16 Read(IXmlPropertyReader reader, string propertyName)
        {
            return Int16.Read(reader, propertyName);
        }
        protected override Int16 Read(IXmlPropertyReader reader, int index)
        {
            return Int16.Read(reader, index);
        }
        protected override void Write(Int16 value, IXmlPropertyWriter writer, string propertyName)
        {
            Int16.Write(writer, propertyName, value);
        }
        protected override void Write(Int16 value, IXmlPropertyWriter writer, int index)
        {
            Int16.Write(writer, index, value);
        }
    }
    public sealed class Int32RuntimeSerializer : XmlRuntimeSerializer<int>
    {
        private Int32RuntimeSerializer() { }
        private static Int32RuntimeSerializer _instance = new Int32RuntimeSerializer();
        public static Int32RuntimeSerializer Instance { get { return _instance; } }
        protected override int Read(IXmlPropertyReader reader, string propertyName)
        {
            return Int32.Read(reader, propertyName);
        }
        protected override int Read(IXmlPropertyReader reader, int index)
        {
            return Int32.Read(reader, index);
        }
        protected override void Write(Int32 value, IXmlPropertyWriter writer, string propertyName)
        {
            Int32.Write(writer, propertyName, value);
        }
        protected override void Write(Int32 value, IXmlPropertyWriter writer, int index)
        {
            Int32.Write(writer, index, value);
        }
    }
    public sealed class Int64RuntimeSerializer : XmlRuntimeSerializer<Int64>
    {
        private Int64RuntimeSerializer() { }
        private static Int64RuntimeSerializer _instance = new Int64RuntimeSerializer();
        public static Int64RuntimeSerializer Instance { get { return _instance; } }
        protected override Int64 Read(IXmlPropertyReader reader, string propertyName)
        {
            return Int64.Read(reader, propertyName);
        }
        protected override Int64 Read(IXmlPropertyReader reader, int index)
        {
            return Int64.Read(reader, index);
        }
        protected override void Write(Int64 value, IXmlPropertyWriter writer, string propertyName)
        {
            Int64.Write(writer, propertyName, value);
        }
        protected override void Write(Int64 value, IXmlPropertyWriter writer, int index)
        {
            Int64.Write(writer, index, value);
        }
    }
    public sealed class FloatRuntimeSerializer : XmlRuntimeSerializer<float>
    {
        private FloatRuntimeSerializer() { }
        private static FloatRuntimeSerializer _instance = new FloatRuntimeSerializer();
        public static FloatRuntimeSerializer Instance { get { return _instance; } }
        protected override float Read(IXmlPropertyReader reader, string propertyName)
        {
            return Float.Read(reader, propertyName);
        }
        protected override float Read(IXmlPropertyReader reader, int index)
        {
            return Float.Read(reader, index);
        }
        protected override void Write(float value, IXmlPropertyWriter writer, string propertyName)
        {
            Float.Write(writer, propertyName, value);
        }
        protected override void Write(float value, IXmlPropertyWriter writer, int index)
        {
            Float.Write(writer, index, value);
        }
    }
    public sealed class DoubleRuntimeSerializer : XmlRuntimeSerializer<double>
    {
        private DoubleRuntimeSerializer() { }
        private static DoubleRuntimeSerializer _instance = new DoubleRuntimeSerializer();
        public static DoubleRuntimeSerializer Instance { get { return _instance; } }
        protected override double Read(IXmlPropertyReader reader, string propertyName)
        {
            return Double.Read(reader, propertyName);
        }
        protected override double Read(IXmlPropertyReader reader, int index)
        {
            return Double.Read(reader, index);
        }
        protected override void Write(Double value, IXmlPropertyWriter writer, string propertyName)
        {
            Double.Write(writer, propertyName, value);
        }
        protected override void Write(Double value, IXmlPropertyWriter writer, int index)
        {
            Double.Write(writer, index, value);
        }
    }
    public sealed class DecimalRuntimeSerializer : XmlRuntimeSerializer<decimal>
    {
        private DecimalRuntimeSerializer() { }
        private static DecimalRuntimeSerializer _instance = new DecimalRuntimeSerializer();
        public static DecimalRuntimeSerializer Instance { get { return _instance; } }
        protected override decimal Read(IXmlPropertyReader reader, string propertyName)
        {
            return Decimal.Read(reader, propertyName);
        }
        protected override decimal Read(IXmlPropertyReader reader, int index)
        {
            return Decimal.Read(reader, index);
        }

        protected override void Write(Decimal value, IXmlPropertyWriter writer, string propertyName)
        {
            Decimal.Write(writer, propertyName, value);
        }
        protected override void Write(Decimal value, IXmlPropertyWriter writer, int index)
        {
            Decimal.Write(writer, index, value);
        }
    }
    public sealed class StringRuntimeSerializer : XmlRuntimeSerializer<string>
    {
        private StringRuntimeSerializer() { }
        private static StringRuntimeSerializer _instance = new StringRuntimeSerializer();
        public static StringRuntimeSerializer Instance { get { return _instance; } }
        protected override string Read(IXmlPropertyReader reader, string propertyName)
        {
            return String.Read(reader, propertyName);
        }
        protected override string Read(IXmlPropertyReader reader, int index)
        {
            return String.Read(reader, index);
        }
        protected override void Write(String value, IXmlPropertyWriter writer, string propertyName)
        {
            String.Write(writer, propertyName, value);
        }
        protected override void Write(String value, IXmlPropertyWriter writer, int index)
        {
            String.Write(writer, index, value);
        }
    }
    public sealed class EnumRuntimeSerializer : XmlRuntimeSerializer<object>
    {
        private Type _type;
        public EnumRuntimeSerializer(Type type) { _type = type; }
        protected override object Read(IXmlPropertyReader reader, string propertyName)
        {
            return Enum.Read(reader, propertyName);
        }
        protected override object Read(IXmlPropertyReader reader, int index)
        {
            return Enum.Read(reader, index);
        }
        protected override void Write(object value, IXmlPropertyWriter writer, string propertyName)
        {
            Enum.Write(writer, propertyName, value);
        }
        protected override void Write(object value, IXmlPropertyWriter writer, int index)
        {
            Enum.Write(writer, index, value);
        }
    }
}
